= render partial: 'articles/toolbar_upload_img', locals: {text_id: 'article_comment_content'}
- if defined?(new_comment) && new_comment
  - @comment = @article.comments.new
.comment_form
  - url = @comment.new_record? ? article_comments_path(@article) : article_comment_path(@article, @comment)
  = form_for @comment, url: url, role: 'form', remote: true do |f|
    .error#error_message
    .form-group
      %ul.nav.nav-tabs#preview_tab{role: "tablist"}
        %li.active
          = link_to (@comment.new_record? ? '发表评论' : '编辑评论'), '#edit', role: 'tab', 'data-toggle'=>'tab'
        %li
          = link_to '预览', '#preview', role: 'tab', 'data-toggle'=>'tab'
      .tab-content
        .tab-pane.active#edit
          = f.text_area :content, placeholder: '评论内容', class: 'form-control'
        .tab-pane#preview
    .form-group
      = f.submit '提交', class: 'btn btn-success btn-lg btn-block'

:javascript
  $(function(){
    $('#preview_tab a[href="#preview"]').click(function(e){
      e.preventDefault();
      $(this).tab('show');
      preview('article_comment_content', 'preview');
    });
  });